/**
 * Created by Adi(adi@imeth.cn) on 2018/8/29.
 */
import React from 'react';
import Equal from 'src/common/Immutables';
import { autobind } from 'core-decorators';
import { rollout as Rollout } from 'src/common/Reducers';
import { message } from 'antd';

message.config({
  top: 400,
  maxCount: 3,
});

@autobind
class Page extends React.Component {
  constructor(props, content, updater) {
    super(props, content, updater);

    this.state = {};
  }

  shouldComponentUpdate(nextProps, nextState) {
    return this.equal(nextProps, nextState);
  }

  equal(nextProps, nextState) {
    return Equal(this, nextProps, nextState);
  }

  dispatch(action) {
    let { dispatch } = this.props;
    dispatch && dispatch(action);
  }

  render() {
    return null;
  }

  rollout(result, prepare, winners, loser, final) {
    Rollout(result, prepare, winners, loser, final);
  }

  toast(msg = '', type = 'success', duration = 2) {
    message[type](msg, [duration]);
  }
}

export default Page;
